Skip to content

Respect the existing deadline when waiting for a partial batch - #60

Open
harbinresearcher wants to merge 1 commit into
wolph:developfrom
harbinresearcher:codex/preserve-abatcher-deadline
Open

harbinresearcher wants to merge 1 commit into
wolph:developfrom
harbinresearcher:codex/preserve-abatcher-deadline

Conversation

@harbinresearcher

Copy link
Copy Markdown

Closes #59.

abatcher waits a full interval for each next item, even when a nonempty batch already has a deadline. With interval10 and arrivals0 and8, a blocked next item delays the batch until18. The strict deadline comparison also postpones a batch whose last item arrives exactly at10 until20.

Use the remaining deadline for a nonempty batch, clamped to zero, and flush when the deadline is reached. Empty batches retain a full wait so an expired idle deadline cannot cause a busy loop. Existing resets after time/size flushes and pending-source cancellation are preserved. The docstring and changelog describe the timing correction.

Eight deterministic regressions cover arrivals before/on the deadline, numeric/timedelta intervals, and interval-only/size+interval batching. The existing fake-clock test now states both expected batch sequences explicitly: its at-deadline case flushes at equality rather than including the next item.

Validation:

  • New regressions against original code:8failed, with flush times18/20 instead of10. Patched generator module:20passed.
  • Windows CPython3.12.14 full configured suite:361→369passed, the same5IANA timezone-data skips; both100% configured branch coverage.
  • Linux CPython3.10.22 and3.14.8 full configured suites:366→374passed in each, both baseline and patch100% configured branch coverage. Linux dependencies resolved with the project's14-day cutoff.
  • Ruff lint/format, mypy, basedpyright, pyrefly, codespell, and Sphinx warnings-as-errors passed on both pristine and patched Linux checkouts. Windows type checks also passed after explicitly selecting the task environment.
  • Isolated sdist and wheel build passed. The built wheel was installed into a separate target, its import path verified, and all20generator tests passed from that installed module.
  • Independent automated read-only review found no actionable issues. Additional controlled-clock/Future-source probes covered cold idle, late arrivals, consumer pauses and an expired deadline clamped to zero.

AI assistance was used for investigation, implementation, tests, review and this description. No local PyPy/macOS or full interpreter-matrix claim. This fixes the requested wait and deadline comparison; it cannot guarantee scheduling latency on a blocked event loop.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

abatcher waits a full interval again while a partial batch is pending

1 participant